// Copyright 2013 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package dfa.axis.v1_19.matchtables;

/**
 * Mappings of DFA SOAP creative types to MatchTable creative types and
 * enumerations of other ad/creative types.
 *
 * @author Moshe Kahan
 */
final class CreativeTypes {

  /**
   * Mapping of DFA SOAP Creative types to DT types and sub-types.
   */
  enum SoapCreativeType {
    IMAGE(1, "Image", MatchTableCreativeType.IMAGE,
        MatchTableCreativeSubType.IMAGE),
    REDIRECT(2, "Redirect", MatchTableCreativeType.REDIRECT,
        MatchTableCreativeSubType.REDIRECT),
    RICH_MEDIA(3, "HTML In-Page", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.HTML),
    INTERNAL_REDIRECT(4, "Internal Redirect", MatchTableCreativeType.INTERNAL_REDIRECT,
        MatchTableCreativeSubType.INTERNAL_REDIRECT),
    INTERSTITIAL(5, "HTML Interstitial", MatchTableCreativeType.INTERSTITIAL,
        MatchTableCreativeSubType.INTERSTITIAL),
    INTERSTITIAL_INTERNAL_REDIRECT(6, "Interstitial Internal Redirect",
        MatchTableCreativeType.INTERSTITIAL_INTERNAL_REDIRECT,
        MatchTableCreativeSubType.INTERSTITIAL_INTERNAL_REDIRECT),
    TRACKING_TEXT(7, "Tracking Text", MatchTableCreativeType.TEXT_LINK,
        MatchTableCreativeSubType.TEXT_LINK),
    TRACKING_IMAGE(8, "Tracking Image", MatchTableCreativeType.TEXT_LINK,
        MatchTableCreativeSubType.TRACKING_IMAGE),
    TRACKING_HTML(9, "Tracking HTML", MatchTableCreativeType.TEXT_LINK,
        MatchTableCreativeSubType.TRACKING_HTML),
    RICH_MEDIA_FLASH_BANNER(10, "Flash Banner", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.RICH_MEDIA_FLASH_BANNER),
    RICH_MEDIA_FLASH_BANNER_INSIGHT_TAG(11,
        "Flash Banner with Insight Express AdInsights Flex Tag",
        MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.RICH_MEDIA_FLASH_BANNER_INSIGHT_TAG),
    RICH_MEDIA_FLASH_BANNER_DL_TAG(12, "Flash Banner with Dynamic Logic AdIndex UTAG",
        MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.RICH_MEDIA_FLASH_BANNER_DL_TAG),
    RICHMEDIA_BANNER(13, "Rich Media In-Page", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.MOTIF_BANNER),
    RICHMEDIA_INPAGE_FLOAT(14, "Rich Media In-Page with Floating",
        MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.MOTIF_BANNER_FLOAT),
    RICHMEDIA_INPAGE_POPUP(15, "Rich Media In-Page with Pop", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.MOTIF_BANNER_POPUP),
    RICHMEDIA_IMAGE_FLOAT(16, "Rich Media Image with Floating", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.MOTIF_IMAGE_BANNER_FLOAT),
    RICHMEDIA_IMAGE_POPUP(17, "Rich Media Image with Pop", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.MOTIF_IMAGE_BANNER_POPUP),
    RICHMEDIA_EXPANDO(18, "Rich Media Expanding", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.MOTIF_EXPANDO),
    RICHMEDIA_INTERSTITIAL_FLOAT(19, "Rich Media Floating", MatchTableCreativeType.INTERSTITIAL,
        MatchTableCreativeSubType.MOTIF_INTERSTITIAL_FLOAT),
    RICHMEDIA_INTERSTITIAL_POPUP(20, "Rich Media Pop", MatchTableCreativeType.INTERSTITIAL,
        MatchTableCreativeSubType.MOTIF_INTERSTITIAL_POPUP),
    RICHMEDIA_INTERSTITIAL_FLOAT_WITH_REMINDER(21, "Rich Media Floating with Reminder",
        MatchTableCreativeType.INTERSTITIAL,
        MatchTableCreativeSubType.MOTIF_INTERSTITIAL_FLOAT_REMINDER),
    INTERSTITIAL_POPUP(23, "Interstitial Pop-Up", MatchTableCreativeType.INTERSTITIAL,
        MatchTableCreativeSubType.INTERSTITIAL_POPUP),
    RICH_MEDIA_FLASH_INPAGE(24, "Flash In-Page", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.RICH_MEDIA_FLASH_INPAGE),
    RICHMEDIA_FLASH_IN_FLASH(28, "Rich Media Flash-in-Flash", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.MOTIF_FLASH_IN_FLASH),
    INSTREAM_VIDEO(29, "In-Stream Video", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.INSTREAM_VIDEO),
    MOBILE_DISPLAY(30, "Mobile Display", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.MOBILE_DISPLAY),
    VPAID_LINEAR(31, "VPAID Linear", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.VPAID_LINEAR),
    VPAID_NON_LINEAR(32, "VPAID Linear", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.VPAID_NON_LINEAR),
    RICH_MEDIA_PEEL_DOWN(32, "Rich Media Peel Down", MatchTableCreativeType.RICH_MEDIA,
        MatchTableCreativeSubType.RICH_MEDIA_PEEL_DOWN);

    private long id;
    private String name;
    private MatchTableCreativeType matchTableCreativeType;
    private MatchTableCreativeSubType matchTableCreativeSubType;

    SoapCreativeType(long id, String name, MatchTableCreativeType matchTableCreativeType,
        MatchTableCreativeSubType matchTableCreativeSubType) {
      this.id = id;
      this.name = name;
      this.matchTableCreativeType = matchTableCreativeType;
      this.matchTableCreativeSubType = matchTableCreativeSubType;
    }

    /**
     * Retrieve SoapCreativeType with this id.
     * @param id SOAP id embedded in Creative DTO.
     * @return SoapCreative type associated with that id.
     */
    static SoapCreativeType getById(long id) {
      for (SoapCreativeType soapCreativeType : values()) {
        if (soapCreativeType.id == id) {
          return soapCreativeType;
        }
      }
      return null;
    }

    String getName() {
      return name;
    }

    MatchTableCreativeType getMatchTableCreativeType() {
      return matchTableCreativeType;
    }

    MatchTableCreativeSubType getMatchTableCreativeSubType() {
      return matchTableCreativeSubType;
    }
  }

  /**
   * Enumeration of all DT creative types.
   */
  enum MatchTableCreativeType {

    IMAGE(0, "Image"),
    REDIRECT(1, "Redirect"),
    RICH_MEDIA(2, "HTML"),
    INTERNAL_REDIRECT(3, "Internal Redirect"),
    TEXT(4, "Text"),
    TEXT_LINK(5, "Text Link"),
    INTERSTITIAL(6, "Interstitial"),
    INTERSTITIAL_INTERNAL_REDIRECT(7, "Interstitial Internal Redirect");

    private long id;
    private String name;

    MatchTableCreativeType(long id, String name) {
      this.id = id;
      this.name = name;
    }

    long getId() {
      return id;
    }

    String getName() {
      return name;
    }
  }

  /**
   * Enumeration of all DT creative sub-types.
   */
  enum MatchTableCreativeSubType {

    IMAGE(0, "Image"),
    REDIRECT(1, "Redirect"),
    HTML(2, "HTML"),
    INTERNAL_REDIRECT(3, "Internal Redirect"),
    TEXT(4, "Text"),
    TEXT_LINK(5, "Text Link"),
    INTERSTITIAL(6, "Interstitial"),
    INTERSTITIAL_INTERNAL_REDIRECT(7, "Interstitial Internal Redirect"),
    MULTITYPE(8, "Multitype"),
    SYSTEM_DEFAULT(9, "System Default"),
    RICH_MEDIA_REDIRECT(10, "Rich Media Redirect"),
    TRACKING_IMAGE(11, "Tracking Image"),
    TRACKING_HTML(12, "Tracking HTML"),
    PARKAY(13, "Parkay"),
    PARKAY_INTERSTITIAL(14, "Parkay Interstitial"),
    MOTIF_BANNER(15, "Motif Banner"),
    MOTIF_FLOAT(16, "Motif Float"),
    MOTIF_POPUP(17, "Motif Popup"),
    MOTIF_BANNER_FLOAT(18, "Motif Banner Float"),
    MOTIF_BANNER_POPUP(19, "Motif Banner Popup"),
    MOTIF_IMAGE_BANNER_FLOAT(20, "Motif Image Banner Float"),
    MOTIF_IMAGE_BANNER_POPUP(21, "Motif Image Banner Popup"),
    MOTIF_EXPANDO(22, "Motif Expando"),
    RICHMEDIA_INPAGE_MOBILE_APP(23, "Rich Media In-Page Mobile App"),
    MOTIF_INTERSTITIAL_FLOAT(24, "Motif Interstitial Float"),
    MOTIF_INTERSTITIAL_POPUP(25, "Motif Interstitial Popup"),
    UNUSED2(26, "Unused2"),
    MOTIF_INTERSTITIAL_FLOAT_REMINDER(27, "Motif Interstitial Float Reminder"),
    MOTIF_FLASH_IN_FLASH(28, "Motif Flash in Flash"),
    STREAMING_REAL(29, "Streaming Real"),
    STREAMING_WINDOWS(30, "Streaming Windows"),
    STREAMING_FLASH(31, "Streaming Flash"),
    INSTREAM_TRACKING(32, "In-Stream Tracking"),
    MOBILE_DISPLAY(33, "Mobile Display"),
    MOBILE_JUMP_PAGE(34, "Mobile Jump Page"),
    RICH_MEDIA_FLASH_BANNER(35, "Flash Banner"),
    RICH_MEDIA_FLASH_BANNER_INSIGHT_TAG(36,
        "Flash Banner with Insight Express AdInsights Flex Tag"),
    RICH_MEDIA_FLASH_BANNER_DL_TAG(37, "Flash Banner with Dynamic Logic AdIndex UTAG"),
    INTERSTITIAL_POPUP(39, "Interstitial Pop-Up"),
    MOBILE_AD_NETWORK(40, "Mobile Ad Network"),
    STREAMING_SILVERLIGHT(41, "Streaming Silverlight"),
    ADSENSE_CALLOUT(42, "Adsense Callout"),
    FLASH_STANDARD(43, "Flash Standard"),
    FLASH_STANDARD_INTERSTITIAL(44, "Flash Standard Interstitial"),
    RICH_MEDIA_FLASH_INPAGE(46, "Flash In-Page"),
    INSTREAM_VIDEO(47, "In-Stream Video"),
    VPAID_LINEAR(50, "VPAID Linear"),
    VPAID_NON_LINEAR(51, "VPAID Non-Linear"),
    RICH_MEDIA_PEEL_DOWN(100, "Rich Media Peel Down");

    private long id;
    private String name;

    MatchTableCreativeSubType(long id, String name) {
      this.id = id;
      this.name = name;
    }

    long getId() {
      return id;
    }

    String getName() {
      return name;
    }
  }

  /**
   * Enumeration of all creative rotation type for RotationGroup ads.
   */
  enum CreativeRotationType {
    Sequential(1, "Sequential"),
    Random(2, "Random"),
    Weighted(3, "Weighted"),
    BestPerforming(4, "Best Performing"),
    Optimized(5, "Optimized"),
    AdvancedOptimization(6, "Advanced Optimization");

    CreativeRotationType(long id, String name) {
      this.id = id;
      this.name = name;
    }

    long getId() {
      return id;
    }

    String getName() {
      return name;
    }

    private long id;
    private String name;
  }

  private CreativeTypes() {}
}
